// pages/group/group.js
var g = require("../../utils/group");

Page({
  changeCategory: function (e) {
    this.setData({
      category: e.currentTarget.id
    })

  },
  /**
   * 页面的初始数据
   */
  shuru: function (e) {
    this.setData({
      neirong: e.detail.value
    })
  },
  cansai: function (e) {
    this.setData({
      index: e.currentTarget.id,
      biaozhi: true
    });
  },
  sousuo() {
    var neirong = this.data.neirong;
    var matches = g.matches;
    var result = [];
    for (let i = 0; i < matches.length; i++) {
      var data = matches[i];
      if (data.name.match(neirong)) {
        result.push(data);
      }
    }
    this.setData({
      result: result,
    })
  },
  click() {
    var neirong = this.data.neirong;
    var groups = g.groups;
    var result = [];
    for (let i = 0; i < groups.length; i++) {
      var data = groups[i];
      if (data.name.match(neirong)) {
        result.push(data);
      }
    }
    this.setData({
      result: result
    })
  },
  dianji: function (e) {
    this.setData({
      index: e.currentTarget.id,
      flag: true,
    });
  },
  data: {
    titles: g.list,
    category: 1,
    neirong: null,
    result: [],
    index: 0,
    flag: false,
    biaozhi: false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})